﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using System.IO;

namespace QLDBNH_CLIENT
{
    class XML
    {
        public void Write_Dangnhap(int i)
        {
            FileStream fs = new FileStream("dangnhap.xml", FileMode.Create);
            XmlTextWriter w = new XmlTextWriter(fs, Encoding.UTF8);

            w.WriteStartDocument();
            w.WriteStartElement("dangnhap");

            w.WriteElementString("stt", i.ToString());
            w.WriteEndElement();

            w.WriteEndDocument();
            w.Flush();
            fs.Close();
        }

        public int Read_Dangnhap()
        {
            int i = 0;

            FileStream fs = new FileStream("dangnhap.xml", FileMode.Open);
            XmlTextReader r = new XmlTextReader(fs);

            while (r.Read())
            {
                if (r.NodeType == XmlNodeType.Element){ }
                else if (r.NodeType == XmlNodeType.Text)
                {
                    i = int.Parse(r.Value);
                }
            }
            fs.Close();

            return i;
        }

    }
}
